import {BaseProps} from "../App";
import React from "react";
import {ProjectApi} from "../framework/api/ProjectApi";

export interface IndexState {
    projectNone: boolean
}

export class Index extends React.Component<BaseProps, IndexState> {
    constructor(props: BaseProps) {
        super(props);
        this.state = {
            projectNone: false
        }
    }

    componentDidMount(): void {
        ProjectApi.list().then(projects => {
            if (projects.length === 0) {
                this.setState({projectNone: true})
            } else if (this.props.location.pathname === '/') {
                this.props.history.push("/" + projects[0].id + "/home")
            }
        });
    }

    render(): React.ReactElement | string | number | {} | React.ReactNodeArray | React.ReactPortal | boolean | null | undefined {
        return <div>

        </div>;
    }
}